﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Threading;

namespace FullDuplexServiceExample
{
	public class MyService : IMyService
	{
		private static IMyCallback GetCallback()
		{
			var callBack = OperationContext.Current.GetCallbackChannel<IMyCallback>();
			return callBack;
		}

		public void SendMsg(MyMsg msg)
		{
			Debug.WriteLine(msg);
			Thread.Sleep(1000);

			var callback = GetCallback();
			callback.ResponseToSentMsg(new MyMsg { Time = DateTime.Now, Text = "Message = " + msg });
		}
	}
}
